﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using MTUnity.Utils;


public class UI_Location_Title : MonoBehaviour
{
    public Text Txt_CNName;
    public Text Txt_ENName;
    public Text Txt_Code;
    public GameObject Obj_FullViewCode;
    public Button Btn_Clicked;

    public delegate void LocationClickedDel();

    private LocationClickedDel del_Callback;
    private int m_iLocationID;


    // Start is called before the first frame update
    void Start()
    {
        Btn_Clicked.onClick.AddListener(OnButtonClicked);
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void SetLocation(FLocation location , bool iSpecific = true)
    {
        
        //Txt_ENName.text = location.ENName;
        Txt_Code.text = location.Code;
        if (location.LocationType == ELocationType.E_Interior)
        {
            if (Obj_FullViewCode != null)
            {
                Obj_FullViewCode.SetActive(true);
            }
            Txt_Code.gameObject.SetActive(false);
        }
        else
        {
            if (Obj_FullViewCode != null)
            {
                Obj_FullViewCode.SetActive(false);
            }
            Txt_Code.text = location.Code;
            Txt_Code.gameObject.SetActive(true);
        }

        m_iLocationID = location.ID;

        string strTitleName = "";
        if (iSpecific)
        {
            strTitleName = location.CNName;
        }
        else
        {
            switch (location.LocationType)
            {
                case ELocationType.E_Interior:
                    strTitleName = "内景";
                    break;
                case ELocationType.E_Enter:
                case ELocationType.E_Exit:
                    strTitleName = "出入口";
                    break;
                case ELocationType.E_NormalSorting:
                    strTitleName = "普通分拣线";
                    break;
                case ELocationType.E_UnNormalSorting:
                    strTitleName = "异形分拣线";
                    break;
                default:
                    break;
            }
        }
        Txt_CNName.text = strTitleName;
    }

    public void OnButtonClicked()
    {
        if (del_Callback != null)
        {
            del_Callback();
        }
        
    }

    public void SetCallback(LocationClickedDel del)
    {
        del_Callback = del;
    }
}
